package haierhome.krund.cn.daggertworetrofitrxjavamvp.retrofit.bean;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Bob on 2016/3/3.
 */
public class SuceesContent {

    /**
     * success : GET登录成功
     */

    private String success;

    public static SuceesContent objectFromData(String str) {

        return new Gson().fromJson(str, SuceesContent.class);
    }

    public static SuceesContent objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), SuceesContent.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<SuceesContent> arraySuceesContentFromData(String str) {

        Type listType = new TypeToken<ArrayList<SuceesContent>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<SuceesContent> arraySuceesContentFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<SuceesContent>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public void setSuccess(String success) {
        this.success = success;
    }

    public String getSuccess() {
        return success;
    }
}
